import AdminLayout from "@/layouts/admin-layout";

import oj from "./modules/admin/oj";

const name = "admin";

export default [
  {
    path: "/admin",
    name: "admin",
    redirect: { name: `${name}-dashboard` },
    meta: { auth: true },
    component: AdminLayout,
    children: [
      {
        path: "dashboard",
        name: `${name}-dashboard`,
        meta: {
          title: "主控台",
          closable: false
        },
        component: () => import("@/pages/admin/dashboard")
      },
      {
        path: "log",
        name: `${name}-log`,
        meta: {
          title: "前端日志"
        },
        component: () => import("@/pages/admin/log")
      },
      // 刷新页面 必须保留
      {
        path: "refresh",
        name: "refresh",
        hidden: true,
        component: {
          beforeRouteEnter(to, from, next) {
            next(instance => instance.$router.replace(from.fullPath));
          },
          render: h => h()
        }
      },
      // 页面重定向 必须保留
      {
        path: "redirect/:route*",
        name: "redirect",
        hidden: true,
        component: {
          beforeRouteEnter(to, from, next) {
            next(instance =>
              instance.$router.replace(JSON.parse(from.params.route))
            );
          },
          render: h => h()
        }
      }
    ]
  },
  oj
];
